package cn.ray.springframework.beans.factory.support;

import cn.ray.springframework.beans.factory.config.BeanDefinition;
import cn.ray.springframework.core.io.DefaultResourceLoader;
import cn.ray.springframework.core.io.ResourceLoader;


//为各种具体的Bean定义读取器（xml/annotation)提供一个公共的基础实现
public abstract class AbstractBeanDefinitionReader implements BeanDefinitionReader{
    //存放bean定义的注册表
    private final BeanDefinitionRegistry registry;

    //加载资源的工具 提供多种资源加载方式
    private ResourceLoader resourceLoader;

    protected AbstractBeanDefinitionReader(BeanDefinitionRegistry registry){
        this(registry,new DefaultResourceLoader());
    }
    protected AbstractBeanDefinitionReader(BeanDefinitionRegistry registry,ResourceLoader resourceLoader){
        this.registry=registry;
        this.resourceLoader=resourceLoader;
    }

    //实现两个get函数方便外部调用把Bean注入类，传递进来
    @Override
    public BeanDefinitionRegistry getRegistry() {
        return registry;
    }

    @Override
    public ResourceLoader getResourceLoader() {
        return resourceLoader;
    }
}
